<?php
	require '../global.php';
	$db_config = require ROOT.'/tool/database/data.php';
	if(isset($_GET['m'])){
		$module_name = trim($_GET['m']);
		$tables = array();
		foreach ($db_config['tables'] as $table_name => &$table) {
			if(array_key_exists('module', $table)){
				foreach ($table['module'] as $m){
					if($m == $module_name){
						$tables[$table_name] = $table;
					}
				}
			}else{
				if($module_name == 'other'){
					$tables[$table_name] = $table;
				}
			}
		}
?>
<table class="detail_list_table" cellspacing="1">
	<tr class="title">
		<th>表名</th>
		<th>模块</th>
		<th>记录数</th>
		<th>数据大小</th>
		<th>索引大小</th>
		<th>字段</th>
		<th>备注</th>
	</tr>
	<tr><td colspan="7" id="mt"></td></tr>
<?php 
foreach ($tables as $table_name => $table) {
?>
<tr>
	<td>
		<a href="javascript:load_table_info('<?php echo $table_name?>')">
			[<?php echo $table_name;?>] <?php echo $table['name']?>
		</a>
		<a href="javascript:void(0);" onclick="edit_table('<?php echo $table_name?>')">修改</a>
	</td>
	<td>
	<?php 
	if(array_key_exists('module', $table)){
		foreach ($table['module'] as $m){
			$db_config['module'][$m];
			echo '<a href="javascript:load_table_info(\'module:'. $m .'\')">'.$db_config['module'][$m]['name'].'</a>　';
		}
	}else{
		echo '<a href="javascript:load_table_info(\'module:other\')">'.$db_config['module']['other']['name'].'</a> ';
	}
	?>
	</td>
	<td class="right"><?php echo $table['table_rows']?></td>
	<td class="right"><?php echo $table['data_length']?></td>
	<td class="right"><?php echo $table['index_length']?></td>
	<td class="right"><?php echo sizeof($table['fields']) ?></td>
	<td><?php echo $table['description']?></td>
</tr>
<?php 
}
?>
</table>
<?php 
	}else{
		echo '此暂未数据表！';
	}
?>